package com.shopping_assistant.view;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.location.Location;
import android.location.LocationListener;

import com.google.android.maps.MapView;
import com.google.android.maps.MyLocationOverlay;

public class SALocationOverlay extends MyLocationOverlay{

	private List<LocationListener> locationListeners;
	
	public SALocationOverlay(Context context, MapView mapView) {
		super(context, mapView);
		
		locationListeners = new ArrayList<LocationListener>(1);
	}
	
	@Override
	public synchronized void onLocationChanged(Location location) {
		super.onLocationChanged(location);
		
		for(LocationListener listener : locationListeners)
			listener.onLocationChanged(location);
	}
	
	public void addLocationListener(LocationListener listener) {
		if(!locationListeners.contains(listener))
			locationListeners.add(listener);
	
	}
	
	public void removeLocationListener(LocationListener listener) {
		locationListeners.remove(listener);
	}
}
